﻿Imports System.Collections.Generic
Imports DataStreams.Csv
Imports System.IO

Public Class Main


    Public Shared ServicesPath As String
    Public Shared bandwidth As String
    Dim power As String
    Public Shared ContagiousTVWS As String
    Public Shared tvws As New List(Of InitializeData.TVWS)
    Dim systems As New List(Of InitializeData.SecondarySystem)

    

    Public Sub New()
        tvws = getTvws()
        ReadCsv()


        Dim solution As New Dictionary(Of InitializeData.TVWS(), InitializeData.SecondarySystem)(MyProblem.solve(systems))
        

        Dim oWrite As System.IO.StreamWriter
        oWrite = File.CreateText("Results.html")
        oWrite.Write(MyProblem.result.ToString())
        Dim ShowDialog As New ShowDialog

    End Sub

    Public Function getTvws() As List(Of InitializeData.TVWS)
        tvws = New List(Of InitializeData.TVWS)
        For i As Integer = 40 To 60
            Select Case i
                Case 40
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 4, True))
                    Next k
                Case 41
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 4, True))
                    Next k
                Case 42
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 4, True))
                    Next k
                Case 43
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 2, True))
                    Next k
                Case 44
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 0, False))
                    Next k
                Case 45
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 2, True))
                    Next k
                Case 46
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 4, True))
                    Next k
                Case 47
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 2, True))
                    Next k
                Case 48
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 0, False))
                    Next k
                Case 49
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 2, True))
                    Next k
                Case 50
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 4, True))
                    Next k
                Case 51
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 4, True))
                    Next k
                Case 52
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 4, True))
                    Next k
                Case 53
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 2, True))
                    Next k
                Case 54
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 0, False))
                    Next k
                Case 55
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 2, True))
                    Next k
                Case 56
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 0, False))
                    Next k
                Case 57
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 2, True))
                    Next k
                Case 58
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 4, True))
                    Next k
                Case 59
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 4, True))
                    Next k
                Case 60
                    For k As Integer = 0 To 8
                        tvws.Add(New InitializeData.TVWS(i, k, 1, 4, True))
                    Next k
            End Select
        Next i
        Return tvws
    End Function

    Public Sub ReadCsv()
        Dim id As Integer = 0
        Dim pick As New Pick("Pick Services File")
        Dim services As New CsvReader(ServicesPath)
        services.ReadHeaders()
        While (services.ReadRecord())
            Dim service As String = services.Item("service")
            power = services.Item("power")
            bandwidth = services.Item("bandwidth")
            Dim priority As String = services.Item("priority")
            Dim start As String = services.Item("start")
            Dim endi As String = services.Item("end")
            If (service.Equals("FDD")) Then
                systems.Add(New InitializeData.SecondarySystem("LTE DL", id, CInt(bandwidth), CInt(power), CInt(priority), CInt(start), CInt(endi)))
                systems.Add(New InitializeData.SecondarySystem("LTE UL", id, CInt(bandwidth), CInt(power), CInt(priority), CInt(start), CInt(endi)))
            ElseIf (service.Equals("WiFi")) Then
                systems.Add(New InitializeData.SecondarySystem("WiFi", id, CInt(bandwidth), CInt(power), CInt(priority), CInt(start), CInt(endi)))
            ElseIf (service.Equals("TDD")) Then
                systems.Add(New InitializeData.SecondarySystem("LTE TDD", id, CInt(bandwidth), CInt(power), CInt(priority), CInt(start), CInt(endi)))
            ElseIf (service.Equals("Public Safety")) Then
                systems.Add(New InitializeData.SecondarySystem("Public Safety", id, CInt(bandwidth), CInt(power), CInt(priority), CInt(start), CInt(endi)))
            End If
            id = id + 1
        End While
        services.Close()
    End Sub

    

End Class
